﻿@inject IHttpService _httpService


<div>
    <CnGalWebSite.Components.Containers.MasaTitleContainer Icon="@IconType.Home.ToIconString()" Title="正文" Class="mb-4" Collapable Outline OutlineHead>
        <MRow>
            <MCol Cols="12" Md="6">
                <CnGalWebSite.Components.Images.UploadButton ShowCropper @bind-ImagePath="@Model.MainPicture" Type="ImageAspectType._16_9" Text="上传主图" Class="mb-4" />
             </MCol>
             <MCol Cols="12">
                 <MTextField @bind-Value="Model.Title" Label="标题" />
             </MCol>
             <MCol Cols="12">
                 <MTextarea Rows="5" @bind-Value="Model.BriefIntroduction" Label="简介" />
             </MCol>
             <MCol Cols="12">
                 <MTextarea Rows="5" @bind-Value="Model.MainPage" Label="主页" />
             </MCol>
         </MRow>
     </CnGalWebSite.Components.Containers.MasaTitleContainer>
     <CnGalWebSite.Components.Containers.MasaTitleContainer Icon="@IconType.Infor.ToIconString()" Title="基本信息" Class="mb-4" Collapable Outline OutlineHead>
        <MRow>
            <MCol Cols="12" Md="6">
                <CnGalWebSite.Components.Inputs.MasaSelecte @bind-Value="Model.Type" TValue="ArticleType" Label="类别" />
            </MCol>
            <MCol Cols="12" Md="6">
                <MTextField @bind-Value="Model.NewsType" Label="动态类型" />
            </MCol>
            <MCol Cols="12" Md="6">
                <CnGalWebSite.Components.Inputs.MasaDatePicker ShowDate ShowTime @bind-Value="Model.PublishTime" Label="原文发布时间" />
             </MCol>
             <MCol Cols="12">
                 <MTextField @bind-Value="Model.Link" Label="原文链接" />
             </MCol>
         </MRow>
     </CnGalWebSite.Components.Containers.MasaTitleContainer>
     <CnGalWebSite.Components.Containers.MasaTitleContainer Icon="@IconType.Link.ToIconString()" Title="关联信息" Class="mb-4" Collapable Outline OutlineHead>
        <MRow>
            <MCol Cols="12" Md="6">
                <MTextField @bind-Value="Model.Author" Label="作者" />
            </MCol>
            <MCol Cols="12" Md="6">
                <MTextField @bind-Value="Model.WeiboId" Label="微博Id" />
            </MCol>
            <MCol Cols="12" Md="6">
                <CnGalWebSite.Components.Inputs.MasaAutoComplete @bind-Value="@Model.AuthorEntryName" Label="关联词条名称" AutoCompleteItems="Items" />
            </MCol>
            </MRow>
        <CnGalWebSite.Shared.MasaComponent.Shared.Editors.Cards.Relevances.InputRelevancesListTip AutoCompleteItems="@Items" Model="Model.Entries" Title="词条"></CnGalWebSite.Shared.MasaComponent.Shared.Editors.Cards.Relevances.InputRelevancesListTip>
    </CnGalWebSite.Components.Containers.MasaTitleContainer>
</div>

@code {
    [Parameter]
    public EditGameNewsModel Model { get; set; }

    private List<string> Items { get; set; } = new List<string>();
    [CascadingParameter]
    public ErrorHandler ErrorHandler { get; set; }
    protected override async Task OnInitializedAsync()
    {
        try
        {
            Items = await _httpService.GetAsync<List<string>>("api/home/GetSearchTipList");
            StateHasChanged();
        }
        catch (Exception ex)
        {
            await ErrorHandler.ProcessError(ex, "获取所有词条名称失败");
        }
    }
}
